package com.ruoyi.product.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.business.domain.product.TbOrderItem;
import com.ruoyi.business.service.product.TbOrderItemService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单明细Controller
 */
@RestController
@RequestMapping("/order/item")
public class TbOrderItemController extends BaseController {

    @Autowired
    private TbOrderItemService tbOrderItemService;

    /**
     * 查询订单明细列表
     */
    @GetMapping("/list")
    @SaCheckPermission("order:item:list")
    public TableDataInfo list(TbOrderItem tbOrderItem) {

        List<TbOrderItem> list = tbOrderItemService.list();
        return null;
    }
    /**
     * 获取订单明细详细信息
     */
    @GetMapping(value = "/{id}")
    @SaCheckPermission("order:item:query:id")
    public R<TbOrderItem> getInfo(@PathVariable("id") Long id) {
        return R.ok(tbOrderItemService.getById(id));
    }
    /**
     * 新增订单明细
     */
    @PostMapping
    @SaCheckPermission("order:item:add")
    public R add(@RequestBody TbOrderItem tbOrderItem) {
        return toAjax(tbOrderItemService.save(tbOrderItem));
    }

    /**
     * 修改订单明细
     */
    @PutMapping
    @SaCheckPermission("order:item:edit")
    public R edit(@RequestBody TbOrderItem tbOrderItem) {
        return toAjax(tbOrderItemService.updateById(tbOrderItem));
    }
    /**
     * 删除订单明细
     */
    @SaCheckPermission("order:item:remove")
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids) {
        return toAjax(tbOrderItemService.removeByIds(java.util.Arrays.asList(ids)));
    }
}
